
<template>
  <el-form  :label-position="labelPosition"  label-width="70px" ref="form" :model="form">

    <el-form-item prop="nodeName" label="节点名称" >
      <el-input size= "small" type="text" placeholder="" style="width: 70%"  v-model="form.nodeName"></el-input>
    </el-form-item>

    <el-form-item prop="nodeNum" label="节点编码">
      <el-input size= "small" type="text"  placeholder="" style="width: 70%"  v-model="form.nodeNum"></el-input>
    </el-form-item>

    <el-form-item prop="execForm" label="处理表单" v-if="form.nodeType === 'task'">
      <el-input size= "small" type="text"  placeholder="" style="width: 70%"  v-model="form.execForm"></el-input>
    </el-form-item>

    <el-row>
      <el-col :span="10">
        <el-form-item prop="rejectFlag" label="允许退回" v-if="form.nodeType === 'task'">
          <el-switch
              v-model="form.rejectFlag"
              active-text="允许"
              inactive-text="不允许">
          </el-switch>
        </el-form-item>
      </el-col>

      <el-col :span="14">
        <el-form-item prop="canRejectNode" label="退回节点" v-if="form.nodeType === 'task'  && form.rejectFlag">
          <el-select v-model="canRejectNodeList" multiple placeholder="请选择">
            <el-option
                v-for="item in preTaskNodes"
                :key="item.nodeId"
                :label="item.nodeName"
                :value="item.nodeId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>

    <el-form-item prop="discRules" label="条件" v-if="form.nodeType === 'path'">
      <el-input size= "small" type="text"  placeholder="" style="width: 70%"  v-model="form.discRules"></el-input>
    </el-form-item>

    <el-form-item prop="forkRules" label="分支规则" v-if="form.nodeType === 'fork'">
      <el-radio v-model="form.forkRules" label="ALL">流向所有分支</el-radio>
      <el-radio v-model="form.forkRules" label="ONE">手动选择一个</el-radio>
      <el-radio v-model="form.forkRules" label="ONE_MORE">手动选择一个或多个</el-radio>
    </el-form-item>

    <el-form-item prop="joinRules" label="聚合规则" v-if="form.nodeType === 'join'">
      <el-radio v-model="form.forkRules" label="ALL">必须所有都完成</el-radio>
      <el-radio v-model="form.forkRules" label="ONE">只要一个完成ONE</el-radio>
    </el-form-item>

    <el-form-item prop="desc" label="描述">
      <el-input size= "small" type="textarea" style="width: 70%"  v-model="form.desc"></el-input>
    </el-form-item>
  </el-form>
</template>
<script>
import {getPreTaskNodes} from '@/api/workflowProcess'
import { utils } from '../utils/common.js'
export default {
  data(){
    return {
      labelPosition:'right',
      form: {
        nodeType:"",
        nodeName:"",
        nodeNum:"",
        execForm:"",
        discRules:"",
        forkRules:"",
        joinRules:"",
        rejectFlag:true,
        canRejectNode:"",
        desc:""
      },
      canRejectNodeList:[],
      preTaskNodes:[],
      processId:"",
    }
  },
  watch:{
    canRejectNodeList(val){
      this.form.canRejectNode = val.join(";");
    }
  },
  created(){

  },
  methods:{
    showPro(node){
      this.processId = utils.getUrlParams("processId");
      this.form = node;
      if(node.canRejectNode != null){
        this.canRejectNodeList = node.canRejectNode.split(";");
      }
      this.form.nodeType = node.type;
      this.queryPreTaskNodes();
    },
    async queryPreTaskNodes(){
      let res = await getPreTaskNodes({processId:this.processId,nodeId:this.form.id});
      this.preTaskNodes = res.data;
    }

  }
}
</script>

<style scoped lang="scss">

</style>